/**
 * HP Subscriber, Network, and Application Policy
 *
 * Copyright (C) 2009-2014 Hewlett-Packard Company
 */
package com.hp.snap.gr.action;


import com.hp.snap.gr.exception.ActionException;
import com.hp.snap.gr.model.jaxb.ActionType;

import java.util.Map;

/**
 * The handler of action, GR Manager provides some default action handler implementation for actions with specific function, for example:
 * shell execution, JMX invocation, SNMP Trap message sending, file replacement and etc.
 * <p/>
 * It also supports to customize more action handler implementation for the GeneralAction type.
 *
 * @author Joey Yi
 */
public interface ActionHandler {

    /**
     * Pre-process the cloned action definition for replace the variables
     *
     * @param action  the action definition to be processed
     * @param context the context for template
     * @throws com.hp.snap.gr.exception.ActionException
     */
    void preProcess(ActionType action, Map<String, Object> context) throws ActionException;

    /**
     * Execute an action, which can be an action with specific functions or GeneralAction for customized functions
     *
     * @param action            The action object/definition
     * @param actionPlanInputs  The global input parameters for all actions in this action plan
     * @param actionPlanOutputs The global output parameters for all actions in this action plan
     * @throws ActionException
     */
    void execute(ActionType action, Map<String, Object> actionPlanInputs, Map<String, Object> actionPlanOutputs) throws ActionException;

}
